home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / oath.lha / oath / test / ms1.cc < prev    next >
C/C++ Source or Header  |  1991-08-29  |  2KB  |  49 lines

  1. #include "oath/minString.h"
  2.  
  3. #include <iostream.h>
  4.  
  5. /////////////////////////////////////////////////////////////////////////////
  6. // Test of minStrings
  7.  
  8. main()
  9.    {characterA R = characterA::make('r');
  10.     characterA S = characterA::make('s');
  11.     characterA T = characterA::make('t');
  12.     characterA L = characterA::make('l');
  13.     characterA N = characterA::make('n');
  14.     characterA E = characterA::make('e');
  15.     characterA A = characterA::make('a');
  16.  
  17.     stringA Star   = minStringA::make() << T << A << R;
  18.     cout << Star.am() << "\t(" << Star.hash() << ")" << endl;
  19.  
  20.     stringA Sstare = minStringA::make() << S << Star << E;
  21.     cout << Sstare.am() << "\t(" << Sstare.hash() << ")" << endl;
  22.  
  23.     stringPosA Pstare = Sstare.makePos();
  24.     cout << "First char is " << *Pstare << endl;
  25.     Pstare.findMatch("tar");
  26.     cout << "Char after tar is " << *Pstare << endl;
  27.  
  28.     Pstare.reset();
  29.     if(Pstare.canMatch("sta"))
  30.         cout << "It can match 'sta', if you wish." << endl;
  31.  
  32.     if(!!Pstare.match(""))
  33.         cout << "It just matched nothing successfully." << endl;
  34.  
  35.     ///
  36.  
  37.     char * Buffer = new char [50];
  38.     for(int I = 0; I < 5; I++)
  39.        {for(int J = 0; J < 10; J++)
  40.             Buffer[I*10 + J] = J;
  41.        }
  42.     stringA Sbuffer = minStringA::make(Buffer, Buffer+42);
  43.     cout << "Sbuffer is " << Sbuffer.count() << " char's long." << endl;
  44.     char * Buffer2 = new char [40];
  45.     Sbuffer.charStarX(Buffer2, 40);
  46.     if(!memcmp(Buffer, Buffer2, 40))
  47.         cout << "Success!  The buffers are the same!" << endl;
  48.   
  49.    }